/**
 * Created by liu on 15-12-19.
 */

define(['jquery','fullPage','swiper','scrollbar','zoomPic'], function () {
    $(function () {
        $('.page1_bg').css({'display':'block','position':'relative','margin-top':'0','top':'0'});
        $('#fullpage').fullpage({
            vertialCentered:true,
            anchors:['page1','page2','page3','page4','page5','page6','page7'],
            scrollOverflow:false,
            'navigation': true,
            afterRender:function(){
                $.fn.fullpage.setAutoScrolling(true);
            },
            onLeave:function(index, nextIndex, direction) {
                if(nextIndex == 2|| nextIndex == 4 || nextIndex == 6||nextIndex ==7){
                    $('.header').addClass('header_white');
                }
                else{
                    $('.header').removeClass('header_white');
                }
                $('.section').eq(nextIndex-1).addClass('animate');

            },
            afterLoad:function(vanchorLink, index){
                if(index == 1){
                    $('.section').eq(index-1).addClass('animate');
                }
                   $('.section:gt('+(index-1)+')').removeClass('animate');
                 $('.section:lt('+(index-1)+')').removeClass('animate');

            },

        });
        $.fn.fullpage.silentMoveTo(1);
        /*
        page3 swiper
         */
        var mySwiper = new Swiper('.page3_swiper',{
            slidesPerView : 4,
            grabCursor : true,
            //grabCursor : true,
            scrollbar: {
                container : '.swiper-scrollbar',
                hide : false,
            }
        });
        new ZoomPic("focus_Box1");
        new ZoomPic('focus_Box2');
        /*
        page4 swiper
         */
       var page4Swiper = new Swiper('.page4_case_container',{
       });
        $('.page4_arrow').click(function(){
            var n = $.inArray(this,$('.page4_arrow'));
            if(n == 0){
                $('.page4_arrow').removeClass('page4_opacity');
                page4Swiper.swipePrev();
                if(page4Swiper.activeIndex == 0){
                    $('.arrow_prev').addClass('page4_opacity');
                }
            }
            else if(n == 1){
                $('.page4_arrow').removeClass('page4_opacity');
                page4Swiper.swipeNext();
                if(page4Swiper.activeIndex == $('.page4_case').size()-1){
                    $('.arrow_next').addClass('page4_opacity');
                }
            }
        })
    })
});